/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package horizon.util;

import java.awt.Dimension;
import java.awt.Point;

/**
 *
 * @author J_Laptop
 */
public class Vector2 {

    float x = 0;
    float y = 0;

    public Vector2(float p, float l) {

        x = p;
        y = l;

    }

    public Vector2(float p) {

        x = p;
        y = p;

    }

    public Vector2 add(Vector2 p) {

        return new Vector2(x + p.x, y + p.y);

    }

    public Vector2 sub(Vector2 p) {

        return new Vector2(x - p.x, y - p.y);

    }

    public Vector2 mult(Vector2 p) {

        return new Vector2(x * p.x, y * p.y);

    }
     public Vector2 mult(float p) {

        return new Vector2(x * p, y * p);

    }

    public Vector2 div(Vector2 p) {

        return new Vector2(x / p.x, y / p.y);

    }

    public Vector2 div(float f) {

        return new Vector2(x / f, y / f);

    }

    public float getX() {

        return x;

    }

    public float getY() {

        return y;

    }
    
    public Dimension getDim(){
        
        return new Dimension((int)x , (int)y);
        
    }
    public Point getPoint(){
        
        return new Point((int)x , (int)y);
        
    }
    
    public String toString(){
        
        return x + "," + y;
        
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Vector2 other = (Vector2) obj;
        if (Float.floatToIntBits(this.x) != Float.floatToIntBits(other.x)) {
            return false;
        }
        if (Float.floatToIntBits(this.y) != Float.floatToIntBits(other.y)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 29 * hash + Float.floatToIntBits(this.x);
        hash = 29 * hash + Float.floatToIntBits(this.y);
        return hash;
    }
    
}
